package com.teach.service.impl.photo;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.teach.dto.LoginUser;
import com.teach.dto.PhotoUserInformDTO;
import com.teach.entity.PhotoFav;
import com.teach.entity.PhotoPic;
import com.teach.mapper.PhotoFavMapper;
import com.teach.service.photo.PhotoFivService;
import com.teach.service.photo.PhotoPicService;

import lombok.extern.slf4j.Slf4j;

@Service
@Slf4j
public class PhotoFivServiceImpl  implements PhotoFivService{
	
	@Autowired
	private PhotoPicService photoPicService;
	
	@Autowired
	private PhotoFavMapper photoFavMapper;

	@Override
	public int deleteByPrimaryKey(Long photoFavId) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int insert(PhotoFav record) {
		// TODO Auto-generated method stub
		return 0;
	}

	/*
	 * 收藏
	 */
	@Override
	public int insertSelective(PhotoFav record) {
		return photoFavMapper.insertSelective(record);
	}

	@Override
	public PhotoFav selectByPrimaryKey(Long photoFavId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public int updateByPrimaryKeySelective(PhotoFav record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int updateByPrimaryKey(PhotoFav record) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public PhotoUserInformDTO collectInform(LoginUser user, String status) {
		List<PhotoPic> photoPics = photoPicService.selectByWriterId(user.getUserName());
		Map<Long, List<String>> map = new HashMap<Long, List<String>>();
		for (PhotoPic photoPic : photoPics) {
			List<String> list = new ArrayList<String>();
			list.add(photoPic.getPhotoThumbnailPicPath());
			list.add(photoPic.getPhotoWatermarkPicPath());
			map.put(photoPic.getPhotoPicId(), list);
		}
		PhotoUserInformDTO collect = new PhotoUserInformDTO();
		collect.setPhotoAlbumMap(map);
		collect.setVisitors(photoFavMapper.selectCollectInform(map.keySet(), user.getUserName(), status));
		log.debug("dto ==> {}", collect);
		return collect;
	}

	@Override
	public int updateStatus(String status, Long picId, String userId) {
		// TODO Auto-generated method stub
		return photoFavMapper.updateStatus(status, picId, userId);
	}

}
